<template>
	<el-container>
		<el-aside>
		</el-aside>
		<el-container>
			<el-card hadow="never" header="领导信箱设置" style="width: 100%">
				<el-row :gutter="24">
					<el-col :lg="12">
						<el-form-item label="意见接收人" prop="leader">
							<select-user-dialog v-model:accountId="form.leader" :mode="false"/>
						</el-form-item>
					</el-col>
					<el-col :lg="12">
						<el-form-item label="是否匿名" prop="isTop">
							<el-switch v-model="form.isAnonymous" active-value="1" inactive-value="0"></el-switch>
						</el-form-item>
					</el-col>
				</el-row>
				<el-form-item label="人员权限" prop="userRole">
					<select-user-dialog v-model:accountId="form.userRole" :mode="true"/>
				</el-form-item>
				<el-form-item label="部门权限">
					<select-dept-dialog v-model:deptId="form.deptRole" :mode="true"/>
				</el-form-item>
				<el-form-item label="职务权限">
					<select-user-level-dialog v-model:levelId="form.levelRole" :mode="true"/>
				</el-form-item>
				<div style="text-align: center">
					<el-button type="primary" :loading="isSaveing" @click="submit()">设 置</el-button>
				</div>
			</el-card>
		</el-container>
		<el-aside>
		</el-aside>
	</el-container>
</template>

<script>
import selectUserDialog from "@/views/module/selectUserDialog";
import selectDeptDialog from "@/views/module/selectDeptDialog";
import selectUserLevelDialog from "@/views/module/selectUserLevelDialog";

export default {
	name: 'Leader Mail Box Config',
	components: {
		selectUserDialog,
		selectUserLevelDialog,
		selectDeptDialog,
	},
	data() {
		return {
			isSaveing: false,
			form: {
				leader: "",
				isAnonymous: "1",
				userRole: "",
				deptRole: "",
				levelRole: ""
			}
		}
	},
	mounted() {
		this.getLeaderMailboxConfig();
	},
	methods: {
		async submit() {
			this.isSaveing = true;
			var res = await this.$API.info.LeaderMailbox.setLeaderMailboxConfig.post(this.form);
			this.isSaveing = false;
			if (res.code == 200) {
				this.$message.success("操作成功")
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
		},
		async getLeaderMailboxConfig() {
			var res = await this.$API.info.LeaderMailbox.getLeaderMailboxConfig.get();
			if (res.code == 200) {
				this.form = res.data
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
		},
	}
}
</script>

<style>
</style>
